import java.awt.image.BufferedImage;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author whitscot
 */
public class MovingAttack {

    final int SPEED_COEF;
    final int DAMAGE;
    double[] position;
    int[] direction;
    String type;
    String image;
    
    MovingAttack(double[] pos, int[] dir, String typeAtt, String img, int speed, int damage){
        position  = pos;
        direction = resetDirection(dir);
        type = typeAtt;
        image = img;
        SPEED_COEF = setSpeed(speed);
        DAMAGE = damage;
    }

    double[] nextPosition() {
        double[] ret = position;
        if(direction[0] == 1){
            ret[0] += (.25 * SPEED_COEF);
        }
        if(direction[0] == -1){
            ret[0] -= (.25 * SPEED_COEF);
        }
        if(direction[1] == 1){
            ret[1] += (.25 * SPEED_COEF);
        }
        if(direction[1] == -1){
            ret[1] -= (.25 * SPEED_COEF);
        }
        return ret;
    }

    void move() {
        position = nextPosition();
    }

    int[] resetDirection(int[] in) {
        if (in[0] > 1) {
            in[0] = 1;
        }
        if (in[0] < -1) {
            in[0] = -1;
        }
        if (in[1] > 1) {
            in[1] = 1;
        }
        if (in[1] < -1) {
            in[1] = -1;
        }
        return in;
    }
    
    int setSpeed(int in){
      return in >= 1 ? in : 1;
    }
}
